package chapter07

object Test13_SimpleFunction extends App {
  private val list1 = List(1, 3, 5, 87, 7, 9)
  private val list2 = List(("a", 1), ("b", 2), ("c", 3))

  // 1.求和
  println(list1.sum)

  //2.求乘积
  println(list1.product)

  //3.最大最小值
  println(list1.min)
  println(list1.max)

  //4.最大值
  println(list2.maxBy((tuple: (String, Int)) => tuple._2))
  println(list2.maxBy(_._2))

  // 5.排序
  println(list1.sorted)

  // 6.从小到大排序
  println(list1.sorted.reverse)

  println(list1.sorted(Ordering[Int].reverse))
  // 7. sortBy
  println(list2.sortBy(_._2)(Ordering[Int].reverse))

  //8. sortWith 从大到小
  println(list1.sortWith((a: Int, b: Int) => a > b))
  println(list1.sortWith(_ > _))

}
